#    Supsta
#    Copyright (c) 2014 Sebastian Dufner
#
#    This file is part of Supsta.
#
#    Supsta is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Supsta is distributed in the hope that it will be useful,#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

require 'supsta/project/texture_provider'

##

module Supsta

  ##
  # The final abstraction layer to a Filter stack.

  class Texture
    include TextureProvider

    ##
    # Returns a Texture, restoring it from +hash+.

    def self.unhash(hash)
      tex = new(hash[:id], hash[:face], hash[:name], hash[:type])
      Filter.unhash(hash[:child]).insert_below tex if hash[:child]
      tex.mtime, tex.last_compiled = hash[:mtime], hash[:last_compiled]
    end

    def initialize(id, face, name, type)
      @id, @face, @name, @type = id, face, name, type
    end
    attr_accessor :id, :face, :name, :type

    def compile(layer, options = {})
    #
    end

    ##
    # Returns a Hash representing this Texture.
    #
    # <b>See also:</b> ::unhash

    def to_hash
      super.merge!(id: id, face: face, name: name, type: type)
    end

  end
end
